<html><head><title>MDIGadget</title></head>
<body bgcolor="#FFFFDF" link="#009999" vlink="#006666" alink="#006666">
<font face="Arial" size="2"><p align="center"><b><font size="4">MDIGadget()</font></b></p>
<p><b>Syntax</b></p><blockquote>
Result = <font color="#006666"><b>MDIGadget</b></font>(#Gadget, x, y, Width, Height, SubMenu, MenuItem [, Flags])</blockquote>

</blockquote>
<b>Description</b><br><blockquote>

Creates a client area, in which child windows can be displayed. 
These child windows are fully movable and sizable by the user in this area. 

</blockquote><p><b>Parameters</b></p><blockquote>
<style type="text/css">
table.parameters { border-spacing: 0px; border-style: none; border-collapse: collapse; }
table.parameters td { border-width: 1px; padding: 6px; border-style: solid; border-color: gray; vertical-align: top; font-family:Arial; font-size:10pt; }
</style>
<table width="90%" class="parameters">
<tr><td width="10%"><i>#Gadget</i></td>
<td width="90%"> 
A number to identify the new gadget. <a href="../reference/purebasic_objects.html">#PB_Any</a> can 
be used to auto-generate this number. 

</td></tr>
<tr><td><i>x, y, Width, Height</i></td>
<td> 
The position and dimensions of the new gadget. 

</td></tr>
<tr><td><i>SubMenu</i></td>
<td> 
The menu index to which the MDI window items should be added. 
<br>
<br>
An MDIGadget() is always connected to a window Menu (see <a href="../menu/createmenu.html">CreateMenu()</a>). Therefore a MDIGadget() 
can only be put on a window that has a menu attached to it. The gadget will give the user the opportunity 
to select the child windows through one of the windows submenus. In the 'SubMenu' parameter, you have to 
specify the submenu index (created with <a href="../menu/menutitle.html">MenuTitle()</a>) where these items will be attached to (the first submenu 
has the index 0). The Gadget will add a separator at the end of this menu, and then add one item for each 
currently displayed child window. 

</td></tr>
<tr><td><i>MenuItem</i></td>
<td> 
The first menu item index to use for MDI windows. 
<br>
<br>
The gadget will require a set of Menu item identifiers (see the 'MenuID' parameter of <a href="../menu/menuitem.html">MenuItem()</a>) 
to add these menuitems. In the 'MenuItem' parameter of MDIGadget() you have to specify the lowest number that 
the gadget can use for that purpose. It will use numbers above that, when new child windows are added, so 
you need to reserve at least as much numbers as you plan to add items. It is recommended to use a number above 
all menu identifiers of your program, to make sure there is never a collision. 

</td></tr>
<tr><td><i>Flags (optional)</i></td>
<td> 
Flags to modify the gadget behavior. It can be a combination of the following values: 
<pre><font face="Courier New, Courier, mono"size="2">  <font color="#924B72">#PB_MDI_AutoSize</font>       : The gadget will automatically resize itself to fit the parent window.
                           If you have no other gadgets on the window, this is a helpful option.
  <font color="#924B72">#PB_MDI_BorderLess</font>     : There will be no border drawn around the client area.
  <font color="#924B72">#PB_MDI_NoScrollBars</font>   : When the user drags a childwindow outside of the displayed area, there will be no scrollbars.
</font></pre>

</td></tr>
</table>
</blockquote><p><b>Return value</b></p><blockquote>

Returns nonzero on success and zero on failure. If <font color="#924B72">#PB_Any</font> was used as the #Gadget parameter 
then the return-value is the auto-generated gadget number on success. 

</blockquote><p><b>Remarks</b></p><blockquote>

Because of the connection with the window menu, there can only be one MDIGadget() on a window, however you can 
put another one in a second window if you wish. You can only put this gadget directly on a window, you can 
NOT put it inside a <a href="containergadget.html">ContainerGadget()</a>, <a href="splittergadget.html">SplitterGadget()</a> or <a href="panelgadget.html">PanelGadget()</a>. 
<br>
As the whole point of this gadget is to dynamically display data, it is recommended to use the #PB_Any feature to 
populate a child window with gadgets. 
<br>
<br>
When using <a href="addgadgetitem.html">AddGadgetItem()</a> with this gadget, there is actually a new PB <a href="../window/index.html">window</a> 
created. All the functions of the Window library can be used with this new window (except <a href="../window/stickywindow.html">StickyWindow()</a>). 
Of course the number chosen for the new window may not overlap with another open window, otherwise the other window will be 
closed. The MDI Gadget does not return any events. Events concerning the childwindows will be received as normal 
<a href="../window/waitwindowevent.html">window events</a> (<font color="#924B72">#PB_Event_SizeWindow</font>, <font color="#924B72">#PB_Event_CloseWindow</font>, ...) instead. 
<br>
<br>

A 'mini help' can be added to this gadget using <a href="gadgettooltip.html">GadgetToolTip()</a>. 
<br>
<br>
The following functions can be used to manage the gadget contents: 
<br>
<br>
- <a href="countgadgetitems.html">CountGadgetItems()</a> : Return the number of child windows. 
<br>
- <a href="addgadgetitem.html">AddGadgetItem()</a> : Add a new child window to the gadget. 
<br>
- <a href="cleargadgetitems.html">ClearGadgetItems()</a> : Close all child windows. 
<br>
- <a href="getgadgetstate.html">GetGadgetState()</a> : Get the currently focused child window. 
<br>
- <a href="setgadgetstate.html">SetGadgetState()</a> : Set the currently focused window, or arrange the child windows. (see <a href="getgadgetstate.html">GetGadgetState()</a> for more info.) 
<br>
- <a href="setgadgetattribute.html">SetGadgetAttribute()</a>: With the following attributes: 
<pre><font face="Courier New, Courier, mono"size="2">  <font color="#924B72">#PB_MDI_Image</font>    : Set a background image. An ImageID value must be passed as value. (see <a href="../image/imageid.html">ImageID()</a>)
  <font color="#924B72">#PB_MDI_TileImage</font>: Set the tile mode. 0 draws the image just once in the top/left corner, 1 repeats the image to fill the whole area
</font></pre>

This gadget supports the <a href="setgadgetcolor.html">SetGadgetColor()</a> and <a href="getgadgetcolor.html">GetGadgetColor</a> functions with the 
<font color="#924B72">#PB_Gadget_BackColor</font> type to change the background color of the MDI area. 

</blockquote><p><b>Example</b></p><blockquote>

<pre><font face="Courier New, Courier, mono"size="2">  <font color="#924B72">#Main</font> = 0
  <font color="#924B72">#MDIChild</font> = 1
  <b><font color="#006666">If</font></b> <font color="#006666">OpenWindow</font>(<font color="#924B72">#Main</font>, 0, 0, 400, 300, "MDIGadget", <font color="#924B72">#PB_Window_SystemMenu</font> | <font color="#924B72">#PB_Window_ScreenCentered</font> | <font color="#924B72">#PB_Window_SizeGadget</font> | <font color="#924B72">#PB_Window_MaximizeGadget</font>)
    <b><font color="#006666">If</font></b> <font color="#006666">CreateMenu</font>(<font color="#924B72">#Main</font>,<font color="#006666"> WindowID</font>(<font color="#924B72">#Main</font>))
<font color="#006666">      MenuTitle</font>("Menu index 0")
<font color="#006666">      MenuTitle</font>("MDI windows menu")
<font color="#006666">        MenuItem</font>(0, "self created item")
<font color="#006666">        MenuItem</font>(1, "self created item")

<font color="#006666">      MDIGadget</font>(0, 0, 0, 0, 0, 1, 2, <font color="#924B72">#PB_MDI_AutoSize</font>)
<font color="#006666">        AddGadgetItem</font>(0, <font color="#924B72">#MDIChild</font>, "child window")
          <font color="#006666">; add gadgets here...</font>
<font color="#006666">      UseGadgetList</font>(<font color="#006666">WindowID</font>(<font color="#924B72">#Main</font>)) <font color="#006666">; go back to the main window gadgetlist</font>
    <b><font color="#006666">EndIf</font></b>
    <b><font color="#006666">Repeat</font></b> : <b><font color="#006666">Until</font></b> <font color="#006666">WaitWindowEvent</font>()=<font color="#924B72">#PB_Event_CloseWindow</font>
  <b><font color="#006666">EndIf</font></b>
</font></pre>
<p><img src="../HelpPictures/mdigadget.png"></p>

</blockquote><p><b>See Also</b></p><blockquote>

<a href="addgadgetitem.html">AddGadgetItem()</a>, <a href="../window/closewindow.html">CloseWindow()</a>, <a href="countgadgetitems.html">CountGadgetItems()</a>, <a href="cleargadgetitems.html">ClearGadgetItems()</a>, <a href="getgadgetstate.html">GetGadgetState()</a>, <a href="setgadgetstate.html">SetGadgetState()</a>, <a href="getgadgetattribute.html">GetGadgetAttribute()</a>, <a href="setgadgetattribute.html">SetGadgetAttribute()</a>, 
<a href="getgadgetcolor.html">GetGadgetColor()</a>, <a href="setgadgetcolor.html">SetGadgetColor()</a>, <a href="../window/index.html">Window library</a> 

</Blockquote><p><b>Supported OS </b><Blockquote>Windows</Blockquote></p><center><- <a href=listviewgadget.html>ListViewGadget()</a> - <a href=index.html>Gadget Index</a> - <a href=openglgadget.html>OpenGLGadget()</a> ->


</body></html>